package cn.id68.www.http;

import android.os.Handler;
import android.os.Looper;

import java.util.concurrent.Executor;

/**
 * Created by Administrator on 2017/3/20.
 */
public class Platform {

    private static final Platform PLATFORM = findPlatform();

    private static Platform findPlatform() {
        return new Platform();
    }

    public static Platform get(){
        return PLATFORM;
    }

    public Executor defaultCallbackExecutor()
    {
        return new MainThreadExecutor();
    }

    static class MainThreadExecutor implements Executor
    {
        private final Handler handler = new Handler(Looper.getMainLooper());

        @Override
        public void execute(Runnable r)
        {
            handler.post(r);
        }
    }

}
